Skip to content

fix(j5): Claude opens new threads with j5_spawn_agent again - #1239

Merged
Jacksondr5 merged 1 commit into
j5/mainfrom
j5code/spawn-guidance-new-threads
Nov 24, 2026
Merged

Jacksondr5 merged 1 commit into
j5/mainfrom
j5code/spawn-guidance-new-threads

Conversation

@Jacksondr5

Copy link
Copy Markdown
Owner

Problem

On v0.1.11, Claude Sonnet answers "open three new threads" with delegate_task children instead of j5_spawn_agent Peer Agents, then tells the user it opened threads. The advance's eval report traced the drop to upstream's new Claude-only "Text the user must read mid-turn" section, but J5's own Peer Agent line was already weak. It named j5_spawn_agent only for an explicit Peer Agent or standalone agent, never for a "new thread". Upstream's section is unchanged here.

Closes #1208

What changed

One sentence in J5's Peer Agent bullet (packages/provider-core/src/j5/orchestrationInstructions.ts, section 3 of the Codex context entries). Jackson reviews agent-instruction changes himself, so here is the whole bullet's first two sentences, old and new:

Before (j5/main) After
A Peer Agent is a full participant with its own top-level thread that the user can open and message. Use j5_spawn_agent when the user explicitly asks for a Peer Agent or a standalone agent they will talk to, or when a skill you are following names it. When nobody asked for one, … A Peer Agent is a full participant with its own top-level thread that the user can open and message. Use j5_spawn_agent when the user asks for a new thread or another thread, a Peer Agent, or a standalone agent they will talk to, or when a skill you are following names it; never delegate_task or a Subagent for those, and t3_thread_transfer only to fork this conversation. An @persona:ID in that request goes in persona. When nobody asked for one, …

Each clause is there because an eval round needed it:

  • v1 added "a new thread", "never delegate_task or a Subagent", and the @persona routing. Every new-thread case passed on Claude except j5-tt-another-thread-worktree (1/3). Asked for "another thread … using a fresh worktree", Claude still picked delegate_task, which the subagent bullet points worktree work at.
  • v2 added "or another thread". The worktree case went to 3/3, but one fork-control sample ("Fork this conversation into a new thread") now spawned a Peer Agent (2/3).
  • v3 added "t3_thread_transfer only to fork this conversation". The fork control went back to 3/3. This is the shipped text.

I left the tool descriptions of j5_spawn_agent and delegate_task alone. The issue suggested changing them too, but in Claude Code the choice happens at ToolSearch, before any description loads, and the instruction change alone was enough.

Context budget: +178 bytes on both Claude's system append and Codex's additional context. agentContextBudget.json now reads claudeSystemAppendBytes 20621 (was 20443) and codexAdditionalContextBytes 22005 (was 21827). The section is 2,821 bytes, under Codex's 4,000-byte limit per entry. Section 1, which is at 3,993 bytes, is untouched.

Evals

Runner: evals/j5-cli from #1228, --catalog j5, 3 samples per case, --shards 1. Claude Code 2.1.326 with claude-sonnet-5-5 (high effort), and Codex 0.169.0 with gpt-6.1-sol (high effort). "Before" is j5/main at aabc4a14c2 (runner commit ab0a63bdf9); v3 is runner commit 07b8fe50d8, and its instruction text is identical to this branch's. A case fails when half or more of its samples fail (evals/README.md).

Case Claude before v1 v2 v3 (this PR) Codex before v1 v2 v3 (this PR)
j5-tt-three-new-threads-one-per-bug 1/3 3/3 3/3 3/3 1/3 3/3 3/3 3/3
j5-persona-new-thread-uses-spawn 0/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3
j5-delegates-then-new-thread-with-model 0/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3
j5-tt-another-thread-worktree 0/3 1/3 3/3 2/3 3/3 3/3 3/3 3/3
j5-tt-thread-in-another-project 0/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3
control: j5-persona-mention-uses-delegate 0/3 0/3 0/3 0/3 3/3 3/3 3/3 3/3
control: j5-fork-thread-uses-transfer 3/3 3/3 2/3 3/3 3/3 3/3 3/3 3/3
control: j5-tt-new-chat-handoff-cross-provider 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3
All 7/24 19/24 20/24 20/24 22/24 24/24 24/24 24/24
  • Claude: all five new-thread cases now pass, and they were 0–1/3 before. That is above base's level in the advance report (6/13 on three-new-threads).
  • Codex: no regression. Its two earlier failures on three-new-threads forked with t3_thread_transfer, which the report listed as pre-existing; that case is now 3/3.
  • Pre-existing, not addressed here: j5-persona-mention-uses-delegate fails 0/3 on Claude before and after. On a bare @persona:reviewer mention, Sonnet calls delegate_task without persona, as the advance report found on both builds. The wording here doesn't change it, and fixing it would mean editing section 1, which is full.

Usage (subscriptions; Claude Code's API-price figure measures load, not spend):

Run Claude agent (input / cached / output) Claude API-price figure Codex agent (input / cached / output)
before 229,010 / 2,352,924 / 25,234 $1.40 543,178 / 1,742,080 / 10,944
v1 258,996 / 2,674,952 / 27,788 $1.58 396,351 / 1,867,392 / 11,453
v2 260,585 / 2,736,765 / 29,627 $1.61 403,383 / 1,830,272 / 11,257
v3 250,691 / 2,757,461 / 27,802 $1.56 361,208 / 1,870,976 / 11,342
Total (192 samples) 999,282 / 10,522,102 / 110,451 $6.15 1,704,120 / 7,310,720 / 44,996

The shell simulator (claude-haiku-5-5) used under 9,000 input tokens per run, about $0.00.

Upstream impact

  • apps/server/src/provider/agentContextBudget.json: data under FORK.md case 110. The new values are what the test measures.
  • orchestrationInstructions.ts and its test are J5-owned. Upstream's CLAUDE_SEND_TO_USER_INSTRUCTIONS is not touched.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior: the evals above; the instruction test's copy assertion follows the new sentence, and AgentContextBudget.test.ts passes
  • UI changes: none
  • Live testing: not done. The evals ran the real Claude Code and Codex CLIs against this text, which is the behavior that changed
  • Upstream-owned files: agentContextBudget.json is case 110's data file. Its FORK.md text records the advance-time numbers and is unchanged
  • Upstream product: no change to what upstream's product does
  • Surfaces: every harness gets these sections. Claude and Codex were evaluated; the others get the same text
  • Docs: no definitions change

Claude Opus 5.5 in Claude Code (J5 Code).

🤖 Generated with Claude Code

J5's Peer Agent line named j5_spawn_agent only for an explicit Peer Agent or a
standalone agent, so on v0.1.11 Sonnet answered "open N new threads" with
delegate_task. The line now names new and other threads, rules out delegate_task
and Subagents for them, keeps forks on t3_thread_transfer, and routes an
@persona:ID in such a request to persona.

Closes #1208

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Nov 24, 2026 3:39am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 34 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 48f2540 and e459d10.

Files selected for processing: 3

  • apps/server/src/provider/agentContextBudget.json
  • packages/provider-core/src/j5/orchestrationInstructions.test.ts
  • packages/provider-core/src/j5/orchestrationInstructions.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions github-actions Bot added size:XS 0-9 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list. labels Nov 24, 2026
@Jacksondr5
Jacksondr5 merged commit ad86c98 into j5/main Nov 24, 2026
38 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/spawn-guidance-new-threads branch November 24, 2026 04:15
Jacksondr5 added a commit that referenced this pull request Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — e459d109 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude opens a delegate instead of a new thread when asked for new threads

1 participant